<template>
  <div>
    <div v-if="isSearch" v-loading="daLoading" class="box_search">
      <div class="login-box">
        <div class="login-form">
          <avatar class="avatar" />
          <Motion>
            <h2 class="outline-none">
              <TypeIt :values="[title]" :cursor="false" :speed="150" />
            </h2>
          </Motion>

          <el-form ref="ruleFormRef" size="large" label-width="80px">
            <Motion :delay="100">
              <el-form-item label="姓名" prop="company">
                <el-input
                  clearable
                  v-model="company"
                  placeholder=""
                  :prefix-icon="useRenderIcon(User)"
                />
              </el-form-item>
            </Motion>
            <Motion :delay="100">
              <el-form-item label="年龄" prop="year">
                <el-input
                  clearable
                  v-model="year"
                  placeholder=""
                  :prefix-icon="useRenderIcon(User)"
                />
              </el-form-item>
            </Motion>
            <Motion :delay="100">
              <el-form-item label="性别" prop="phone">
                <el-input
                  clearable
                  v-model="phone"
                  placeholder=""
                  :prefix-icon="useRenderIcon(User)"
                />
              </el-form-item>
            </Motion>
            <Motion :delay="100">
              <el-form-item label="身份证号" prop="numberid">
                <el-input
                  clearable
                  v-model="numberid"
                  placeholder=""
                  :prefix-icon="useRenderIcon(User)"
                />
              </el-form-item>
            </Motion>
            <Motion :delay="100">
              <el-form-item label="联系方式" prop="phoneemail">
                <el-input
                  clearable
                  v-model="phoneemail"
                  placeholder=""
                  :prefix-icon="useRenderIcon(User)"
                />
              </el-form-item>
            </Motion>
            <Motion :delay="300">
              <el-form-item>
                <div class="w-full h-[20px] flex justify-between items-center">
                  <el-button
                    class="w-full mt-4"
                    size="default"
                    @click="editUser"
                  >
                    查询
                  </el-button>
                </div>
              </el-form-item>
            </Motion>
            <!-- <Motion :delay="150">
              <el-form-item prop="password">
                <el-input
                  clearable
                  show-password
                  v-model="year"
                  :placeholder="t('login.password')"
                  :prefix-icon="useRenderIcon(Lock)"
                />
              </el-form-item>
            </Motion> -->

            <!-- <Motion :delay="200">
              <el-form-item prop="verifyCode">
                <el-input
                  clearable
                  v-model="phone"
                  :placeholder="t('login.verifyCode')"
                  :prefix-icon="useRenderIcon('ri:shield-keyhole-line')"
                >
                  <template v-slot:append>
                    <ReImageVerify v-model:code="imgCode" />
                  </template>
                </el-input>
              </el-form-item>
            </Motion> -->

            <!-- <Motion :delay="250">
              <el-form-item>
                <div class="w-full h-[20px] flex justify-between items-center">
                  <el-checkbox v-model="checked">
                    {{ t("login.remember") }}
                  </el-checkbox>
                  <el-button
                    link
                    type="primary"
                    @click="useUserStoreHook().SET_CURRENTPAGE(4)"
                  >
                    {{ t("login.forget") }}
                  </el-button>
                </div>
                <el-button
                  class="w-full mt-4"
                  size="default"
                  type="primary"
                  :loading="loading"
                  @click="onLogin(ruleFormRef)"
                >
                  {{ t("login.login") }}
                </el-button>
              </el-form-item>
            </Motion> -->
            <!-- 
            <Motion :delay="300">
              <el-form-item>
                <div class="w-full h-[20px] flex justify-between items-center">
                  <el-button
                    v-for="(item, index) in operates"
                    :key="index"
                    class="w-full mt-4"
                    size="default"
                    @click="useUserStoreHook().SET_CURRENTPAGE(index + 1)"
                  >
                    {{ t(item.title) }}
                  </el-button>
                </div>
              </el-form-item>
            </Motion> -->
          </el-form>
        </div>
      </div>

      <!-- <div class="boxs">
        <h2 style="margin-bottom: 30px">账户信息搜索</h2>
        <div class="user_info">
          <el-form
            ref="ruleForm"
            label-width="100px"
            class="demo-ruleForm"
            style="width: 40%"
          >
            <el-form-item label="姓名">
              <el-input v-model="company" clearable></el-input>
            </el-form-item>
            <el-form-item label="年龄">
              <el-input v-model="year" clearable></el-input>
            </el-form-item>
            <el-form-item label="	性别">
              <el-input v-model="phone" clearable></el-input>
            </el-form-item>
            <el-form-item label="身份证号">
              <el-input v-model="numberid" clearable></el-input>
            </el-form-item>
            <el-form-item label="联系方式">
              <el-input v-model="phoneemail" clearable></el-input>
            </el-form-item>
          </el-form>
          <el-button @click="editUser">查询</el-button>
        </div>
      </div> -->
    </div>
    <div v-else>
      <div v-loading="dataLoading">
        <el-descriptions title="个人信息">
          <el-descriptions-item label="姓名">李宇翔</el-descriptions-item>
          <el-descriptions-item label="年龄">32岁</el-descriptions-item>
          <el-descriptions-item label="性别">男</el-descriptions-item>
          <el-descriptions-item label="身份证号">
            <el-tag size="small">310109198801011234</el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="联系方式"
            >13612345678</el-descriptions-item
          >
        </el-descriptions>
        <el-descriptions title="健康状态信息" class="mt-5 mb-5">
          <el-descriptions-item label="心率"
            >110次/分钟（偏高）</el-descriptions-item
          >
          <el-descriptions-item label="心律变异"
            >70ms（偏低）</el-descriptions-item
          >
          <el-descriptions-item label="睡眠质量"
            >深睡：3小时 浅睡：4小时</el-descriptions-item
          >
          <el-descriptions-item label="压力级别" style="display: flex">
            <div style="display: flex">
              <el-tag size="small">中等</el-tag>
              <el-progress
                :text-inside="true"
                :stroke-width="22"
                :percentage="60"
                status="warning"
              />
            </div>
          </el-descriptions-item>
          <el-descriptions-item label="疲劳度">
            <div style="display: flex">
              <el-tag size="small">高</el-tag>
              <el-progress
                :text-inside="true"
                :stroke-width="22"
                :percentage="90"
                status="exception"
              />
            </div>
          </el-descriptions-item>
        </el-descriptions>
        <div style="display: flex">
          <el-col
            :xs="24"
            :sm="24"
            :md="12"
            :lg="8"
            :xl="8"
            class="mb-[18px] mr-3"
            v-motion
            :initial="{
              opacity: 0,
              y: 100
            }"
            :enter="{
              opacity: 1,
              y: 0,
              transition: {
                delay: 400
              }
            }"
          >
            <el-card shadow="never" class="mt-2">
              <template #header>
                <a
                  :class="titleClass"
                  href="https://github.com/pure-admin/vue-pure-admin"
                  target="_black"
                >
                  <TypeIt
                    :className="'type-it1'"
                    :values="['疲劳度测量']"
                    :cursor="false"
                    :speed="120"
                  />
                </a>
              </template>
              <el-skeleton animated :rows="7" :loading="loading">
                <template #default>
                  <Pie />
                </template>
              </el-skeleton>
            </el-card>
          </el-col>
          <el-col
            :xs="24"
            :sm="24"
            :md="12"
            :lg="16"
            :xl="16"
            class="mb-[18px]"
            v-motion
            :initial="{
              opacity: 0,
              y: 100
            }"
            :enter="{
              opacity: 1,
              y: 0,
              transition: {
                delay: 400
              }
            }"
          >
            <el-card shadow="never" class="mt-2">
              <template #header>
                <a
                  :class="titleClass"
                  href="https://github.com/pure-admin/vue-pure-admin"
                  target="_black"
                >
                  <TypeIt
                    :className="'type-it2'"
                    :values="['各项指标监控']"
                    :cursor="false"
                    :speed="120"
                  />
                </a>
              </template>
              <el-skeleton animated :rows="7" :loading="loading">
                <template #default>
                  <Line />
                </template>
              </el-skeleton>
            </el-card>

            <el-button type="primary" @click="handlejyClick" class="mt-2 ml-5"
              >评估与预警</el-button
            >
          </el-col>
        </div>

        <el-dialog
          v-model="formVisible"
          title="健康趋势图"
          :width="680"
          draggable
          :before-close="closeDialog"
        >
          <Line />
          <template #footer>
            <el-button type="primary" @click="handlejyClick"
              >报告生成</el-button
            >
            <el-button @click="closeDialog">关闭</el-button>
          </template>
        </el-dialog>
        <el-dialog
          v-model="formjyVisible"
          title="健康风险评估与预警"
          :width="680"
          draggable
          :before-close="closejyDialog"
        >
          <template #default>
            <Pie2 />
          </template>

          <template #footer>
            <el-button @click="closejyDialog">关闭</el-button>
          </template>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useI18n } from "vue-i18n";
import Motion from "./utils/motion";
import { useRouter } from "vue-router";
import { message } from "@/utils/message";
import { loginRules } from "./utils/rule";

import qrCode from "./components/qrCode.vue";
import regist from "./components/regist.vue";
import update from "./components/update.vue";
import { useNav } from "@/layout/hooks/useNav";
import type { FormInstance } from "element-plus";
import { $t, transformI18n } from "@/plugins/i18n";
import { operates, thirdParty } from "./utils/enums";
import { useLayout } from "@/layout/hooks/useLayout";
import { useUserStoreHook } from "@/store/modules/user";
import { initRouter, getTopMenu } from "@/router/utils";
import { bg, avatar, illustration } from "./utils/static";
import { ReImageVerify } from "@/components/ReImageVerify";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { useTranslationLang } from "@/layout/hooks/useTranslationLang";
import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";

import dayIcon from "@/assets/svg/day.svg?component";
import darkIcon from "@/assets/svg/dark.svg?component";
import globalization from "@/assets/svg/globalization.svg?component";
import Lock from "@iconify-icons/ri/lock-fill";
import Check from "@iconify-icons/ep/check";
import User from "@iconify-icons/ri/user-3-fill";
import TypeIt from "@/components/ReTypeit";
import { ref, watch, computed } from "vue";
import Line from "./components/line.vue";
import Pie from "./components/Pie.vue";
import Pie2 from "./components/Pie2.vue";
import { Search } from "@element-plus/icons-vue";
const daLoading = ref(false);
const datevalue = ref("");
const tableData = ref();
let arrfilter = ref();
const formVisible = ref(false);
const formjyVisible = ref(false);
const dataLoading = ref(false);
const loading = ref<boolean>(true);
interface User {
  date: string;
  name: string;
  xinb: string;
  tz: string;
  xl: string;
  xy: string;
  phone: string;
  idnum: string;
  address: string;
}
const ruleForm = ref();
const company = ref();
const year = ref();
const phone = ref();
const phoneemail = ref();
const numberid = ref();
let isSearch = ref(true);
const rate = ref(3);
const colors = ref(["#99A9BF", "#F7BA2A", "#FF9900"]);
setTimeout(() => {
  loading.value = !loading.value;
}, 800);
const tableRowClassName = ({
  row,
  rowIndex
}: {
  row: User;
  rowIndex: number;
}) => {
  if (rowIndex === 2 || rowIndex === 3) {
    return "warning-row";
  }
  return "";
};

const handleClick = () => {
  if (datevalue.value) {
    tableData.value = [
      {
        date: "2023-01-03",
        name: "陈志明",
        xinb: "男",
        tz: "60kg",
        xl: "70次/分钟",
        xy: "稳定",
        phone: "13835401380",
        idnum: "347821009123456789",
        address: "深圳市翻斗花园2-1"
      },
      {
        date: "2023-02-03",
        name: "陈志明",
        xinb: "男",
        sg: "180cm",
        tz: "60kg",
        xl: "80次/分钟",
        xy: "稳定",
        phone: "13835401380",
        idnum: "303874512345678901",
        address: "深圳市翻斗花园2-1"
      },
      {
        date: "2023-03-03",
        name: "陈志明",
        xinb: "男",
        sg: "180cm",
        tz: "60kg",
        xl: "110次/分钟",
        xy: "心律不齐",
        phone: "13835401380",
        idnum: "303874512345678901",
        address: "深圳市翻斗花园2-1"
      },
      {
        date: "2023-04-03",
        name: "陈志明",
        xinb: "男",
        sg: "180cm",
        tz: "60kg",
        xl: "108次/分钟",
        xy: "心律不齐",
        phone: "13835401380",
        idnum: "303874512345678901",
        address: "深圳市翻斗花园2-1"
      },
      {
        date: "2023-05-03",
        name: "陈志明",
        xinb: "男",
        sg: "180cm",
        tz: "60kg",
        xl: "88次/分钟",
        xy: "稳定",
        phone: "13835401380",
        idnum: "303874512345678901",
        address: "深圳市翻斗花园2-1"
      },
      {
        date: "2023-06-03",
        name: "陈志明",
        xinb: "男",
        sg: "180cm",
        tz: "60kg",
        xl: "89次/分钟",
        xy: "稳定",
        phone: "13835401380",
        idnum: "303874512345678901",
        address: "深圳市翻斗花园2-1"
      }
    ];
  } else {
    message("请选择时间段", { type: "warning" });
  }
};
const editUser = () => {
  if (company.value === "李宇翔") {
    daLoading.value = true;
    setTimeout(() => {
      daLoading.value = false;
      isSearch.value = false;
    }, 1600);
  } else {
    message("该用户未注册", { type: "warning" });
  }
};
const { title, getDropdownItemStyle, getDropdownItemClass } = useNav();
const handlejyClick = () => {
  formVisible.value = false;
  dataLoading.value = true;
  setTimeout(() => {
    dataLoading.value = false;
    formjyVisible.value = true;
  }, 1600);
};
const closeDialog = () => {
  formVisible.value = false;
};
const closejyDialog = () => {
  formjyVisible.value = false;
};
tableData.value = [];
</script>
<style scoped>
@import url("@/style/login.css");
</style>
<style scoped>
.demo-date-picker {
  display: flex;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
}
.demo-date-picker .block {
  padding: 30px 0;
  text-align: center;
  border-right: solid 1px var(--el-border-color);
  flex: 1;
}
.demo-date-picker .block:last-child {
  border-right: none;
}
.demo-date-picker .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}
::v-deep .el-table .warning-row {
  --el-table-tr-bg-color: var(--el-color-warning-light-9) !important;
}
.el-table .success-row {
  --el-table-tr-bg-color: var(--el-color-success-light-9) !important;
}
.demo-rate-block {
  padding: 30px 0;
  text-align: center;
  border-right: solid 1px var(--el-border-color);
  display: inline-block;
  width: 49%;
  box-sizing: border-box;
}
.demo-rate-block:last-child {
  border-right: none;
}
.demo-rate-block .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}
.demo-progress .el-progress--line {
  margin-bottom: 15px;
  width: 250px;
}
.el-progress {
  width: 260px;
  margin-left: 10px;
}
.login-box {
  display: flex;
  align-items: center;
  text-align: center;
  justify-content: center;
  padding-top: 8%;
}
</style>
<style>
.el-descriptions__body {
  padding: 10px;
}
</style>
<style scoped>
@import url("@/style/login.css");
</style>
